/* **********************************************************************************
*
* Copyright (c) Microsoft Corporation. All rights reserved.
*
* This source code is subject to terms and conditions of the Shared Source License
* for DSL Editor PowerToy. A copy of the license can be found in the License.htm file
* at the root of this distribution. If you can not locate the Shared Source License
* for DSL Editor PowerToy, please obtain a copy from: http://www.codeplex.com/dsltreegrideditor/Project/License.aspx.
* By using this source code in any fashion, you are agreeing to be bound by
* the terms of the Shared Source License for DSL Editor PowerToy.
*
* You must not remove this notice, or any other, from this software.
*
* **********************************************************************************/
using System;
using System.Text;
using System.Runtime.Serialization;

using EnvDTE80;
using EnvDTE;

using Microsoft.Practices.RecipeFramework;

namespace DslEditorPowerToy.Recipes.References
{
    /// <summary>
    /// Base recipe reference
    /// </summary>
    [Serializable]
    public abstract class RecipeReferenceBase : UnboundRecipeReference
    {
        private EnvDTE.DTE _dte = null;

        #region Constructors
        public RecipeReferenceBase(string template)
            : base(template)
        {
        }
        #endregion

        #region ISerializable Members

        /// <summary>
        /// Required constructor for deserialization.
        /// </summary>
        protected RecipeReferenceBase(SerializationInfo info, StreamingContext context)
            : base(info, context)
        {
        }

        #endregion ISerializable Members

        #region Protected Properties
        /// <summary>
        /// Gets the visual studio automation object
        /// </summary>
        [CLSCompliant(false)]
        protected EnvDTE.DTE DTE
        {
            get
            {
                //Test if already accessed
                if (null == this._dte)
                {
                    //Get visual studio automation object (we cant do this in the ctor)
                    this._dte = (EnvDTE.DTE)GetService(typeof(EnvDTE.DTE));
                }
                return this._dte;
            }
        }

        #endregion
    }
}
